/*
 * Projet industriel MBDS 2012 VAMP
 */
package com.vampmobile.android.db;

import org.json.JSONException;
import org.json.JSONObject;

/*
 * Object Poinotation
 */
public class Poinotation {
	protected Long id=null;
	public Long idmember;
	public Long idpoi;
	public int like;
	public int unlike;
	public int favorite;
	private JSONObject o;

	public Poinotation() {
		o = new JSONObject();
	}
	public Poinotation(JSONObject o) {
		this.o = o;
		like = o.optInt(VampDatabase.POINOTATION_LIKE_COL);
		unlike = o.optInt(VampDatabase.POINOTATION_UNLIKE_COL);
		favorite = o.optInt(VampDatabase.POINOTATION_FAVORITE_COL);
		idmember = o.optLong(VampDatabase.MEMBER_ID_COL);
		idpoi = o.optLong(VampDatabase.POI_ID_COL);
		id = o.optLong(VampDatabase.POINOTATION_ID_COL);
	}
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		if (this.id==null)
			this.id=id;
	}

	public JSONObject toJSONObject() {
		try {
			o.put(VampDatabase.POINOTATION_FAVORITE_COL, favorite);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		try {
			o.put(VampDatabase.POINOTATION_LIKE_COL, like);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		try {
			o.put(VampDatabase.POINOTATION_UNLIKE_COL, unlike);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		try {
			o.put(VampDatabase.POINOTATION_IDAUTHOR_COL, idmember);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		try {
			o.put(VampDatabase.POINOTATION_IDPOI_COL, idpoi);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		try {
			o.put(VampDatabase.POINOTATION_ID_COL, id);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return o;
	}
	
}
